package com.zhiyiang.controller;

import com.zhiyiang.Vo.TypeDataVO;
import com.zhiyiang.pojo.Type;
import com.zhiyiang.service.type.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/type")
public class TypeController {
    @Autowired
    private TypeService typeService;
    @GetMapping("getTypes/{hotelid}")
    public List<Type> getTypes(@PathVariable("hotelid") Integer hotelid){
        return typeService.getTypes(hotelid);
    }

    @GetMapping("/getTypeData/{usercode}")
    public List<TypeDataVO> getTypeData(@PathVariable("usercode") String usercode){
        return typeService.getTypeData(usercode);
    }

    @GetMapping("/getTypeList")
    public List<Type> getTypeList(){
        return typeService.getTypeList();
    }

    @PostMapping("/addType")
    public void addType(@RequestBody Type type){
        typeService.addType(type);
    }

    @GetMapping("/getTypeById/{id}")
    public Type getTypeById(@PathVariable Integer id){
        return typeService.getTypeById(id);
    }

    @PostMapping("/updateType")
    public void updateType(@RequestBody Type type){
        typeService.updateType(type);
    }

    @DeleteMapping("/deleteType/{id}")
    public void deleteType(@PathVariable Integer id){
        typeService.deleteType(id);
    }
}
